;var meiGaoApp = window.meiGaoApp || {};
meiGaoApp = function(){
  return {
    init:function(){
      var _this = this;
      _this.incSlideFun();
    },
    incSlideFun:function(){
        var  _this = this;
        var swiperH = new Swiper('.swiper-container-h', {
            direction: 'vertical',
            paginationClickable: true,
            spaceBetween: 50,
            onSlideChangeEnd: function(swiper){
              console.log(swiper.activeIndex);
              switch(swiper.activeIndex){
                  case 1:
                    _this.ajaxSendPageData(1);
                    $('#menuListBtn').show();
                  break;
                  case 2:
                    _this.ajaxSendPageData(2);
                    $('#menuListBtn').show();
                  break;
                  case 3:
                    _this.ajaxSendPageData(3);
                    $('#menuListBtn').show();
                  break;
                  case 4:
                    _this.ajaxSendPageData(4);
                    $('#menuListBtn').show();
                  break;
                  case 5:
                    _this.ajaxSendPageData(5);
                    $('#menuListBtn').show();
                  break;
                  default:
                    $('#menuListBtn').hide();
                  break;
              };
            }
        });
        var swiperA = new Swiper('.swiper-container-a', {
            paginationClickable: true,
            direction: 'horizontal',
            spaceBetween: 50,
            nextButton: '.swiper-button-next',
            prevButton: '.swiper-button-prev'
        });
        var swiperB = new Swiper('.swiper-container-b', {
            paginationClickable: true,
            direction: 'horizontal',
            spaceBetween: 50,
            nextButton: '.swiper-button-next',
            prevButton: '.swiper-button-prev'
        });

        $('.ban1_main').on('click','a',function(){
          var _index = $(this).index();
          // console.log(_index);
          switch(_index){
            case 0:
              swiperH.slideTo(1, 500, true);
            break;
            case 1:
              swiperH.slideTo(2, 500, true);
            break;
            case 2:
              swiperH.slideTo(3, 500, true);
            break;
            case 3:
              swiperH.slideTo(4, 500, true);
            break;
            case 4:
              swiperH.slideTo(7, 500, true);
            break;
            default:
              console.log(22222);
            break;
          }
        });
        $('.ban4_main').on('click','a',function(){
          var _index = $(this).index();
          // console.log(_index);
          switch(_index){
            case 0:
              swiperA.slideTo(5, 500, true);
            break;
            case 1:
              swiperA.slideTo(4, 500, true);
            break;
            case 2:
              swiperA.slideTo(6, 500, true);
            break;
            case 3:
              swiperA.slideTo(3, 500, true);
            break;
            case 4:
              swiperA.slideTo(2, 500, true);
            break;
            case 5:
              swiperA.slideTo(1, 500, true);
            break;
            default:
              console.log(22222);
            break;
          }
        });
        $('.ban6_main').on('click','a',function(){
          var _index = $(this).index();
          // console.log(_index);
          swiperB.slideTo(_index+1, 500, true);
        });
        $('#menuListBtn').on('click',function(){
          swiperH.slideTo(0, 500, true);
        });
    },
    ajaxSendPageData:function(index){
        var typeData = 'meigao',
            pageData = index;
        $.post("http://duoduojf.com/meitai/index.php/wechat/setread", {type: typeData, page: pageData});
        

    },
    isVertical:function(){
      var w = $(window).width(),
          h = $(window).height();
      if(w < h){
        $('#page').width(h);
        $('#page').height(w);
        return true;
      }else{
        $('#page').width(w);
        $('#page').height(h);
      }
      return false;
    },
    lodingFun:function(){

      var _rootPic = window.winPath,
          _this = this;

      var picArr = [
        _rootPic+'/img/loding.gif',
        _rootPic+'/img/mg_ban1_pic1.png',
        _rootPic+'/img/mg_ban1_pic2.png',
        _rootPic+'/img/mg_ban1_pic3.png',
        _rootPic+'/img/mg_ban1_pic4.png',
        _rootPic+'/img/mg_ban1_pic5.png',
        _rootPic+'/img/mg_ban1_pic6.png',
        _rootPic+'/img/mg_ban_01.png',
        _rootPic+'/img/mg_ban_02.png',
        _rootPic+'/img/mg_ban_03.png',
        _rootPic+'/img/mg_ban_04.png',
        _rootPic+'/img/mg_ban_05_01.png',
        _rootPic+'/img/mg_ban_05_02.png',
        _rootPic+'/img/mg_ban_05_03.png',
        _rootPic+'/img/mg_ban_05_04.png',
        _rootPic+'/img/mg_ban_05_05.png',
        _rootPic+'/img/mg_ban_05_06.png',
        _rootPic+'/img/mg_ban_06_01.png',
        _rootPic+'/img/mg_ban_06_01_01.png',
        _rootPic+'/img/mg_ban_06_01_02.png',
        _rootPic+'/img/mg_ban_06_01_03.png',
        _rootPic+'/img/mg_ban_06_01_04.png',
        _rootPic+'/img/mg_ban_06_02.png',
        _rootPic+'/img/mg_ban_06_03.png',
        _rootPic+'/img/mg_ban_06_04.png',
        _rootPic+'/img/mg_ban_06_05.png',
        _rootPic+'/img/mg_ban_07.png',
        _rootPic+'/img/mg_ban_08.png',
      ];
      var imgNum = 0;
        $.imgpreload(picArr,{
          each: function(){
            var status = $(this).data('loaded') ? 'success' : 'error';
            if (status == "success") {                
                var v = (parseFloat(++imgNum) / picArr.length).toFixed(2);
                $("#comLoding .jindu").html(Math.round(v * 100) + "%");
            }
          },
          all: function(){
            if(!_this.isVertical()){
              $('#comLoding').hide();
              _this.init();
            };
          }
        });
    }
  }
};
function hengshuping(){
  if(window.orientation==180||window.orientation==0){ 
        window.location.reload()
   }
  if(window.orientation==90||window.orientation==-90){ 
        window.location.reload()
    } 
}
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", hengshuping, false); 
